define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'fruitwarriorachieve/index',
                    add_url: 'fruitwarriorachieve/add',
                    edit_url: 'fruitwarriorachieve/edit',
                    del_url: 'fruitwarriorachieve/del',
                    multi_url: 'fruitwarriorachieve/multi',
                    table: 'fruit_warrior_achieve',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'login_num', title: __('Login_num')},
                        {field: 'level', title: __('Level')},
                        {field: 'video_num', title: __('Video_num')},
                        {field: 'all_normal_weapon', title: __('All_normal_weapon')},
                        {field: 'all_special_weapon', title: __('All_special_weapon')},
                        {field: 'share_num', title: __('Share_num')},
                        {field: 'one_cut_num', title: __('One_cut_num')},
                        {field: 'lucky_wheel_num', title: __('Lucky_wheel_num')},
                        {field: 'watermelon', title: __('Watermelon')},
                        {field: 'kiwi', title: __('Kiwi')},
                        {field: 'mangosteen', title: __('Mangosteen')},
                        {field: 'peach', title: __('Peach')},
                        {field: 'orange', title: __('Orange')},
                        {field: 'apple', title: __('Apple')},
                        {field: 'bigcherry', title: __('Bigcherry')},
                        {field: 'pitaya', title: __('Pitaya')},
                        {field: 'strawberry', title: __('Strawberry')},
                        {field: 'avocado', title: __('Avocado')},
                        {field: 'banana', title: __('Banana')},
                        {field: 'lemon', title: __('Lemon')},
                        {field: 'cherry', title: __('Cherry')},
                        {field: 'pineapple', title: __('Pineapple')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});